/*
 *  node_test.cc
 *  Untitled
 *
 *  Created by Ben Nolan on 2/11/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#include "node.h"
#include "vector.h"
#include "errors.h"
#include <iostream>

#include <boost/test/unit_test.hpp>

namespace W = Wonderland;

BOOST_AUTO_TEST_CASE(Node_ToString){
	W::Guid guid(69000);
	W::Wid owner("ben@test");
	W::Node n1(guid, owner, owner);
	
	BOOST_CHECK_EQUAL(
		n1.toString(),
		"<node guid=\"10d88\" owner=\"ben@test\" agent=\"ben@test\" position=\"0,0,0\" scale=\"0,0,0\" rotation=\"0,0,0,0\" />\n"
	);
};

BOOST_AUTO_TEST_CASE(Node_NewFromString){
	W::Guid guid(69000);
	W::Wid owner("ben@test");
	W::Node n1(guid, owner, owner);

	BOOST_CHECK_THROW(
		W::Node n2("<node />");,
		Wonderland::Errors::BadSerialization
	);

	BOOST_CHECK_THROW(
		W::Node n2("!!!!!!@<>@!>!@!@>");,
		Wonderland::Errors::BadSerialization
	);

	W::Node n3("<node guid=\"10d88\" owner=\"ben@test\" agent=\"ben@test\" position=\"1,2,3\" scale=\"4,5,6\" rotation=\"2,0,1,0\" />\n");
	
	BOOST_CHECK_EQUAL(guid, n3.guid_);
	BOOST_CHECK_EQUAL(owner, n3.owner_);
	BOOST_CHECK_EQUAL(owner, n3.agent_);
	
	BOOST_CHECK_EQUAL(Wonderland::Vector(1,2,3), n3.position_);
	BOOST_CHECK_EQUAL(Wonderland::Vector(4,5,6), n3.scale_);
	BOOST_CHECK_EQUAL(Wonderland::Quaternion(2,0,1,0), n3.rotation_);
}

	

//	BOOST_CHECK(
//	);
//    // seven ways to detect and report the same error:
//    BOOST_CHECK( add( 2,2 ) == 4 );        // #1 continues on error
//
//    BOOST_REQUIRE( add( 2,2 ) == 4 );      // #2 throws on error
//
//    if( add( 2,2 ) != 4 )
//      BOOST_ERROR( "Ouch..." );            // #3 continues on error
//
//    if( add( 2,2 ) != 4 )
//      BOOST_FAIL( "Ouch..." );             // #4 throws on error
//
//    if( add( 2,2 ) != 4 ) throw "Ouch..."; // #5 throws on error
//
//    BOOST_CHECK_MESSAGE( add( 2,2 ) == 4,  // #6 continues on error
//                         "add(..) result: " << add( 2,2 ) );
//
//    BOOST_CHECK_EQUAL( add( 2,2 ), 4 );	  // #7 continues on error
